#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPushButton>
#include <QFileDialog>
#include <QDebug>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    resize(800, 600);
    QPushButton* btn = new QPushButton("文件", this);

    QFileDialog* fdlg = new QFileDialog(this);

    // connect(btn, &QPushButton::clicked, [=](){
    //     QString str = fdlg->getOpenFileName(this, //父指针
    //                                         "文件", //文件对话框标题
    //                                         "D:/CSDN/my-qt/QtMainWindow/Qt_QFileDialog_1",
    //                                         "*.cpp"
    //                                         );
    // });

    connect(btn, &QPushButton::clicked, [=](){
        QString str = fdlg->getSaveFileName(this, //父指针
                                            "文件", //文件对话框标题
                                            "D:/CSDN/my-qt/QtMainWindow/Qt_QFileDialog_1",
                                            "*.cpp"
                                            );
    });
}

MainWindow::~MainWindow()
{
    delete ui;
}
